/*
 * Copyright (C) 2008 Universidade Federal de Campina Grande
 *  
 * This file is part of OurGrid. 
 *
 * OurGrid is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free 
 * Software Foundation, either version 3 of the License, or (at your option) 
 * any later version. 
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details. 
 * 
 * You should have received a copy of the GNU Lesser General Public License 
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package org.ourgrid.acceptance.worker;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.ourgrid.acceptance.util.WorkerAcceptanceUtil;
import org.ourgrid.acceptance.util.worker.Req_004_Util;
import org.ourgrid.acceptance.util.worker.Req_006_Util;
import org.ourgrid.acceptance.util.worker.Req_079_Util;
import org.ourgrid.acceptance.util.worker.Req_080_Util;
import org.ourgrid.acceptance.util.worker.Req_084_Util;
import org.ourgrid.acceptance.util.worker.Req_090_Util;
import org.ourgrid.acceptance.util.worker.Req_092_Util;
import org.ourgrid.acceptance.util.worker.Req_121_Util;
import org.ourgrid.common.interfaces.Worker;
import org.ourgrid.common.interfaces.WorkerClient;
import org.ourgrid.common.interfaces.management.RemoteWorkerManagementClient;
import org.ourgrid.common.interfaces.management.WorkerManagementClient;
import org.ourgrid.common.interfaces.to.WorkerStatus;
import org.ourgrid.reqtrace.ReqTest;
import org.ourgrid.worker.WorkerComponent;
import org.ourgrid.worker.WorkerConfiguration;
import org.ourgrid.worker.utils.RandomNumberUtil;

import br.edu.ufcg.lsd.commune.identification.ContainerID;
import br.edu.ufcg.lsd.commune.identification.DeploymentID;
import br.edu.ufcg.lsd.commune.processor.filetransfer.IncomingTransferHandle;

@ReqTest(reqs="REQ084")
public class Req_084_Test extends WorkerAcceptanceTestCase {

	private DeploymentID peerID;
	private Req_004_Util req_004_Util = new Req_004_Util(getComponentContext());
	private Req_090_Util req_090_Util = new Req_090_Util(getComponentContext());
	private Req_092_Util req_092_Util = new Req_092_Util(getComponentContext());
	private Req_084_Util req_084_Util = new Req_084_Util(getComponentContext());
	private Req_006_Util req_006_Util = new Req_006_Util(getComponentContext());
	private Req_121_Util req_121_Util = new Req_121_Util(getComponentContext());
	private Req_079_Util req_079_Util = new Req_079_Util(getComponentContext());
	private Req_080_Util req_080_Util = new Req_080_Util(getComponentContext());
	
	@Before
	public void setUp() throws Exception {
		super.setUp();
		String peerPubKey = workerAcceptanceUtil.simulateAuthentication();
		
		peerID = new DeploymentID(new ContainerID("username", "server", "module", peerPubKey), "peer");
		
	}
	
	/**
   	 * 1. Start a Worker with the idleness detector DISABLED;
   	 * 2. The master peer sends a setPeer message to the Worker;
     *     * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
     *     * Expect the Worker to send a status changed message to the peer, with the IDLE status
   	 * 3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
     *     * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
     *     * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
     *     * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
   	 * 4. A client with the public key "mgPublicKey222" tries to execute the remote command "rm -rf *"
     *     * Verify if the following warn message was logged: An unknown client tried to execute the command [rm -rf *]. Unknown client public key: [mgPublicKey222].
     *     * Expect the worker to send a "errorOcurred" message to the WorkerClient. The execution error's type is INVALID_SESSION.
     *     
	 */
	@ReqTest(test=" AT-084.1", reqs="REQ084")
	@Test public void test_at_084_1_UnknownLocalClientTriesToExecuteRemoteCommand() throws Exception {
		
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(
				component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey222" tries to execute the remote command "rm -rf *"
		req_084_Util.remoteExecutionByUnknownClient(component, worker, "mgPublicKey222", "rm -rf *");
	}
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
     *	  2. The master peer sends a setPeer message to the Worker;
     *     * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
     *     * Expect the Worker to send a status changed message to the peer, with the IDLE status
     *	  3. The master peer sends a workForPeer message to the Worker;
     *     * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
     *     * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
     *     * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
     *	  4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
     *     * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
     *     * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
     *     * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
     *	  5. A client with the public key "mgPublicKey222" tries to execute the remote command "rm -rf *";
     *     * Verify if the following warn message was logged: An unknown client tried to execute the command [rm -rf *]. Unknown client public key: [mgPublicKey222].
     *     * Expect the worker to send a "errorOcurred" message to the WorkerClient. The execution error's type is INVALID_SESSION.
	 *
	 */
	
	@ReqTest(test=" AT-084.2", reqs="REQ084")
	@Test public void test_at_084_2_UnknownRemoteClientTriesToExecuteRemoteCommand() throws Exception {
		
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(
				component, peerID, WorkerStatus.IDLE);

		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey222" tries to execute the remote command "rm -rf *"
		req_084_Util.remoteExecutionByUnknownClient(component, worker, "mgPublicKey222", "rm -rf *");
		
	}
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
   	 *	  2. The master peer sends a setPeer message to the Worker;
     *     * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
     *     * Expect the Worker to send a status changed message to the peer, with the IDLE status
   	 *	  3. The master peer commands the Worker to work for the client with the public key "mgPublicKey1";
     *     * Verify if the following info message was logged: "Peer commanded this Worker to work for a local consumer. Local consumer public key: [mgPublicKey1]."
     *     * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_MYGRID."
     *     * Expect the Worker to send the peer an allocated for mygrid status changed message, with a stub to the Worker remote object
   	 *	  4. A client with the public key "mgPublicKey1" tries to execute the remote command "rm -rf *"
     *     * Verify if the following warn message was logged: A client tried to execute the command [rm -rf *] but did not send startwork messagem. Client public key: [mgPublicKey1].
     *     * Expect the worker to send a "errorOcurred" message to the WorkerClient. The execution error's type is INVALID_SESSION.
     *     
	 */
	@ReqTest(test=" AT-084.3", reqs="REQ084")
	@Test public void test_at_084_3_KnownLocalClientTriesToExecuteRemoteCommandInANonWorkingWorker() throws Exception {
		
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(
				component, peerID, WorkerStatus.IDLE);
		
		//Master peer commands the Worker to work for the client with the public key "mgPublicKey1"
		req_092_Util.workForMyGridOnIdleWorker(component, wmc, "mgPublicKey1");
		Worker worker = req_092_Util.beginAllocationCompleted(component, wmc);
		
		//A client with the public key "mgPublicKey1" tries to execute the remote command "rm -rf *"
		req_084_Util.remoteExecutionInANonWorkingWorker(component, worker, "mgPublicKey1", "rm -rf *");
		
	}
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
   	 *	  2. The master peer sends a setPeer message to the Worker;
     *     * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
     *     * Expect the Worker to send a status changed message to the peer, with the IDLE status
     *	  3. The master peer sends a workForPeer message to the Worker;
     *     * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
     *     * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
     *     * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
   	 *    4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
     *     * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
     *     * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
     *     * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
   	 *	  5. A client with the public key "mgPublicKey1" tries to execute the remote command "rm -rf *";
     *     * Verify if the following warn message was logged: A client tried to execute the command [rm -rf *] but did not send startwork messagem. Client public key: [mgPublicKey1].
     *     * Expect the worker to send a "errorOcurred" message to the WorkerClient. The execution error's type is INVALID_SESSION.
     *     
	 */
	@ReqTest(test=" AT-084.4", reqs="REQ084")
	@Test public void test_at_084_4_KnownRemoteClientTriesToExecuteRemoteCommandInANonWorkingWorker() throws Exception {
		
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(
				component, peerID, WorkerStatus.IDLE);

		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		//A client with the public key "mgPublicKey1" tries to execute the remote command "rm -rf *"
		req_084_Util.remoteExecutionInANonWorkingWorker(component, worker, "mgPublicKey1", "rm -rf *");
		
	}
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
     *    2. The master peer sends a setPeer message to the Worker;
     *     * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
     *     * Expect the Worker to send a status changed message to the peer, with the IDLE status
     *	  3. The master peer sends a workForPeer message to the Worker;
     *     * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
     *     * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
     *     * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
   	 *    4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
     *     * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
     *     * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
     *     * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
   	 *	  5. A client with the public key "mgPublicKey1" tries to execute the remote command "rm -rf *";
     *     * Verify if the following info message was logged: "Command scheduled to execution. Command: rm -rf * ; RequestID: requestID ; Environment variables: ; Client public key: [mgPublicKey1].
     *     * Verify if the following error message was logged: "A client is trying to EXECUTE more than one command simultaneously. RequestID: requestID ; command: "echo" ; Environment variables: envVars"
     *     * Expect the worker to send a "errorOcurred" message to the WorkerClient. The execution error's type is CONCURRENT_RUNNING
     *     
	 */
	@ReqTest(test=" AT-084.5", reqs="REQ084")
	@Test public void test_at_084_5_ConsumerTriesToExecuteTwoConsecutiveRemoteCommands() throws Exception {
		
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		Map<String, String> properties = component.getContainer().getContext().getProperties();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(
				component, peerID, WorkerStatus.IDLE);

		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		// Client [mgPublicKey1] sends a startWork - expect an info to be logged
		DeploymentID myGridID = new DeploymentID(new ContainerID("mgUser", "mgServer", "mgModule", "mgPublicKey1"), "mgObj");
		
		WorkerClient workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGridID);
		
		//A client with the public key "mgPublicKey1" tries to execute the remote command "echo echo"
		//The WorkerExecutionClient does not receive an execution result
		long requestID = 1;
		Map<String, String> envVars = new HashMap<String, String>();
		String playpenDir = properties.get(WorkerConfiguration.ATT_PLAYPEN_ROOT);
		String storageDir = properties.get(WorkerConfiguration.ATT_STORAGE_DIR);
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		req_084_Util.remoteExecutionWithNoExecutionResult(component, worker, workerClient, myGridID,
				requestID, envVars, "echo echo", 0);
		
		//A client with the public key "mgPublicKey1" tries to execute the remote command "echo echo"
		//Expect the worker to send a "errorOcurred" message to the WorkerClient. The execution error's type is CONCURRENT_RUNNING
//		req_084_Util.remoteExecutionWithConcurrencyError(component, worker, workerClient, myGridID,
//				requestID, envVars, "echo echo");
		
	}
	
	/**
	 *  1. Start a Worker with the idleness detector DISABLED;
   	 *	2. The master peer sends a setPeer message to the Worker;
     *     * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
     *     * Expect the Worker to send a status changed message to the peer, with the IDLE status
   	 *	3. The master peer sends a workForPeer message to the Worker;
     *     * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
     *     * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
     *     * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
   	 *	4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
     *     * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
     *     * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
     *     * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
   	 *	5. A client with the public key "mgPublicKey1" tries to execute the remote command "touch $PLAYPEN/foo ; touch $STORAGE/baa";
     *     * Verify if the following info message was logged: "Command scheduled to execution. Command: rm playpenDir/foo ; rm storageDir/baa ; RequestID: requestID ; Environment variables: ; Client public key: [mgPublicKey1].
     *     * Expect if the worker schedules an execution action HELP. The execution directory should be the playpen.
     *     * Expect the schedule action to send a executionResult to the WorkerClient
	 *
	 */
	@ReqTest(test=" AT-084.6", reqs="REQ084")
	@Test public void test_at_084_6_SuccessfulExecutionAndRemoteCommandHandling() throws Exception {
		//Start Worker with idleness detector DISABLED
		WorkerComponent component = req_004_Util.startWorker();
		
		Map<String, String> properties = component.getContainer().getContext().getProperties();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(
				component, peerID, WorkerStatus.IDLE);

		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util.workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		// Client [mgPublicKey1] sends a startWork - expect an info to be logged
		DeploymentID myGridID = new DeploymentID(new ContainerID("mgUser", "mgServer", "mgModule", "mgPublicKey1"), "mgObj");
		
		RandomNumberUtil.setSeed(0L);
		WorkerClient workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGridID);
		
		//A client with the public key "mgPublicKey1" tries to execute the remote command "touch $PLAYPEN/foo ; touch $STORAGE/baa";
		long requestID = 1;
		Map<String, String> envVars = new HashMap<String, String>();
		String playpenDir = properties.get(WorkerConfiguration.ATT_PLAYPEN_ROOT);
		String storageDir = properties.get(WorkerConfiguration.ATT_STORAGE_DIR) + "/" + WorkerAcceptanceUtil.generateHexadecimalCodedString(myGridID.getPublicKey());
		envVars.put("STORAGE", storageDir);
		envVars.put("PLAYPEN", playpenDir);
		req_084_Util.remoteExecutionWithSuccess(component, worker, workerClient, myGridID,
				requestID, envVars, "touch $PLAYPEN/foo; touch $STORAGE/baa;", playpenDir, storageDir, 0);
		
	}
	
	/**
	 *    1.  Start a Worker with the idleness detector DISABLED;
   	 *	  2. The master peer sends a setPeer message to the Worker;
     *     * Verify if the following info message was logged: The peer [peerID] set itself as manager of this Worker.
     *     * Expect the Worker to send a status changed message to the peer, with the IDLE status
   	 *	  3. The master peer sends a workForPeer message to the Worker;
     *     * Verify if the following info message was logged: "Peer commanded this Worker to work for a remote peer. Remote peer public key: [peerPubKey]."
     *     * Verify if the following debug message was logged: "Status changed from IDLE to ALLOCATED_FOR_PEER."
     *     * Expect the Worker to send the peer an allocated for peer status changed message, with a stub to the Remote Worker Management remote object
   	 *	  4. The remote peer with the public key "peerPubKey" commands the Worker to work for the remote client with the public key "mgPublicKey1";
     *     * Verify if the following info message was logged: "Remote peer commanded this Worker to work for a remote consumer. Remote consumer public key: [mgPublicKey1]."
     *     * Verify if the following debug message was logged: "Status changed from ALLOCATED_FOR_PEER to ALLOCATED_FOR_MYGRID."
     *     * Expect the Worker to send the remote peer an allocated for mygrid status changed message, with a stub to the Worker remote object
	 *    5. A client with the public key "mgPublicKey1" requests to transfer the file "test_084_8.txt", with size 512 bytes and the handle "1";
	 *     * Verify if the following debug message was logged: A transfer request from the client was successfully accepted. Client public key: [mgPublicKey1] File destination: [playpenDir/file1]. File size: 512 bytes. Handle: 1.
	 *     * Expect the Worker to accept the file transfer;
	 *    6. The Worker receives an incoming transfer completed message, for the file transfer with handle 1 and 512 bytes of written data;
	 *     * Verify if the following debug message was logged: File successfully received from client. Client public key: [mgPublicKey1]. Handle: 1. Amount of data received: 512 bytes.
   	 *	  7. A client with the public key "mgPublicKey1" tries to execute the remote command "touch $PLAYPEN/test_084_8.txt";
     *     * Verify if the following info message was logged: "Command scheduled to execution. Command: touch playpenDir/test_084_8.txt RequestID: requestID ; Environment variables: ; Client public key: [mgPublicKey1].
     *     * Expect if the worker schedules an execution action HELP. The execution directory should be the playpen.
     *     * Expect the schedule action to send a executionResult to the WorkerClient
     *     
	 */
	@ReqTest(test=" AT-084.7", reqs="REQ084")
	@Test public void test_at_084_7_SucessfulRemoteExecutionWithPutFile() throws Exception {
		
		//Start Worker with idleness detector DISABLED
//		Map<String, Object> workerProperties = workerAcceptanceUtil.createWorkerProperties(false);
		WorkerComponent component = req_004_Util.startWorker();
		
		Map<String, String> properties = component.getContainer().getContext().getProperties();
		
		//Master peer sends a setPeer message
		WorkerManagementClient wmc = req_090_Util.setKnownPeer(
				component, peerID, WorkerStatus.IDLE);

		//Master peer sends a workForPeer message
		req_006_Util.workForPeerOnIdleWorker(component, wmc, peerID.getPublicKey(), "peerPubKey");
		
		//The remote peer with the public key "peerPubKey" commands the Worker 
		// to work for the remote client with the public key "mgPublicKey1"
		RemoteWorkerManagementClient rwmc = req_121_Util .workForMyGridOnAllocatedForPeerWorker(component, "peerPubKey", "mgPublicKey1");
		Worker worker = req_121_Util.beginAllocationCompleted(component, rwmc);
		
		// Client [mgPublicKey1] sends a startWork - expect an info to be logged
		DeploymentID myGridID = new DeploymentID(new ContainerID("mgUser", "mgServer", "mgModule", "mgPublicKey1"), "mgObj");
		
		RandomNumberUtil.setSeed(0L);
		WorkerClient workerClient = req_079_Util.startWorkSuccessfully(component, worker, myGridID);
		
		int requestID = 1;
		String fileName = "test_084_8.txt";
		
		String playpenDir = properties.get(WorkerConfiguration.ATT_PLAYPEN_ROOT);
		String storageDir = properties.get(WorkerConfiguration.ATT_STORAGE_DIR) + "/" + WorkerAcceptanceUtil.generateHexadecimalCodedString(myGridID.getPublicKey());
		
		String filePath = playpenDir + File.separator + fileName;
		WorkerAcceptanceUtil.createFile(filePath);
		
		IncomingTransferHandle operationHandle = new IncomingTransferHandle(0, filePath, 512, filePath, "PUT", myGridID.getContainerID());
		
		req_080_Util.requestToTransferFile(component, requestID, myGridID.getContainerID(), 
				fileName, operationHandle, 512);
		
		req_080_Util.receiveIncomingTransferCompleted(component, worker, operationHandle, 512, 
				myGridID.getPublicKey());

		Map<String, String> envVars = new HashMap<String, String>();
		req_084_Util.remoteExecutionWithSuccess(component, worker, workerClient, myGridID,
				requestID, envVars, "touch $PLAYPEN/test_084_8.txt", playpenDir, storageDir, 0);
	}
	
}
